import java.io.BufferedWriter;
import java.io.File;

import java.io.FileWriter;

import java.io.Writer;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**Record whatever has been sent to and received from the server
 
/**
 * @author u0907023
 *
 */
public class Statistics {
	
	
	public static int uploadRequest = 0;
	public static int avgUploadSize = 0;
	
	public static int downloadRequest = 0;	
	public static int avgDownloadSize = 0;
	
	public static int renameRequest = 0;	
	public static int avgRenameSize = 0;
	
	public static int deleteRequest = 0;
	public static int avgDeleteSize = 0;
	
	public static int moveRequest = 0;
	public static int avgMoveSize = 0;
	
	public static int metadataRequest = 0;
	public static int avgMetadataSize = 0;
	
	public static void writeToLog(String record, String filename){
		
		try {
			Writer output = null;
			File file = new File(filename);
			output = new BufferedWriter(new FileWriter(file, true));
			output.append(record+"\n");
			output.flush();
			output.close();
		} catch (Exception e) {
			
		}
		
		
		
	}
	
	public static String getCurrentTime(){
		Calendar calendar = new GregorianCalendar();
	    String am_pm;
   	    int hour = calendar.get(Calendar.HOUR);
		int minute = calendar.get(Calendar.MINUTE);
		int second = calendar.get(Calendar.SECOND);
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		int month = calendar.get(Calendar.MONTH);
		int year = calendar.get(Calendar.YEAR);
		if(calendar.get(Calendar.AM_PM) == 0)
		am_pm = "AM";
		else
		am_pm = "PM";
		  
		String time ="Current Time : " + hour + ":" + minute + ":" + second + " " + am_pm + ", " + day +"-"+ month +"-"+ year;
		return time;
		
	}
}
